package ywpt.components.acegi.domain;

import java.util.HashSet;
import java.util.Set;

public class Role implements java.io.Serializable {
	private static final long	serialVersionUID	= -8949491107977400685L;
	private Long				id;
	private String				roleName;
	private String				description;
	private Integer				version;	
	private Set<User>			users				= new HashSet<User>(0);
	private Set<Resource>		resources			= new HashSet<Resource>(0);
	private Set<Function>		functions			= new HashSet<Function>(0);
	private Set<Operation>		operations			= new HashSet<Operation>(0);

	// Constructors
	/** default constructor */
	public Role() {
	}

	/** full constructor */
	public Role(String roleName, String description, String authorize, Set<User> users, Set<Resource> resources) {
		this.roleName = roleName;
		this.description = description;
		this.users = users;
		this.resources = resources;
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public String getRoleName() {
		return this.roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Set<User> getUsers() {
		return this.users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	public Set<Resource> getResources() {
		return this.resources;
	}

	public void setResources(Set<Resource> resources) {
		this.resources = resources;
	}

	@SuppressWarnings("unchecked")
	public void addResource(Resource resource) {
		getResources().add(resource);
	}

	@SuppressWarnings("unchecked")
	public void removeResource(Resource resource) {
		getResources().remove(resource);
	}

	@SuppressWarnings("unchecked")
	public void addUser(User user) {
		getUsers().add(user);
	}

	@SuppressWarnings("unchecked")
	public void removeUser(User user) {
		getUsers().remove(user);
	}

	public Set<Function> getFunctions() {
		return functions;
	}

	public void setFunctions(Set<Function> functions) {
		this.functions = functions;
	}

	@SuppressWarnings("unchecked")
	public void addFunction(Function function) {
		getFunctions().add(function);
	}

	@SuppressWarnings("unchecked")
	public void removeFunction(Function function) {
		getFunctions().remove(function);
	}

	public Set<Operation> getOperations() {
		return operations;
	}

	public void setOperations(Set<Operation> operations) {
		this.operations = operations;
	}
	
	@SuppressWarnings("unchecked")
	public void addOperation(Operation operation) {
		getOperations().add(operation);
	}

	@SuppressWarnings("unchecked")
	public void removeOperation(Operation operation) {
		getOperations().remove(operation);
	}	
}